<!--导入按钮-->
<template>
  <div class="Export daoru el-card is-always-shadow el-card__body">
    <el-upload
      class="upload-demo"
      action="check/check/uploadXCResult"
      :headers="headers"
      :with-credentials="true"
      :on-success="uploadSuccess"
      >
      <el-button size="mini" type="primary">协查导入</el-button>
    </el-upload>
    <el-dialog
      title="导入预览"
      :visible.sync="dialogVisible"
      width="80%"
      height="90%"
      >
      <avue-crud
        ref="crud"
        :option="option"
        :data="list"
        >

      </avue-crud>

      <span slot="footer" class="dialog-footer">
    <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
    <el-button size="mini" type="primary" @click="exportData">导入</el-button>
  </span>
    </el-dialog>
  </div>
</template>


<script>
  import {getForm, postForm} from '@/api/gen/gen'
  import ExportJsonExcel from "js-export-excel";
  import {
    fenExYuangettoFixed,
    getgetStationCodes,
    getLineCodes, getLineName, getStationName,
    getSwPmDeviceOperationCodeList,
    qianxiangType
  } from "../../../../../../api/subwayRat/commonCheck";
  import {
    import_xc_result,
    importDataSwAuInputInternetTicketEquipmentDetails,
    mondifySwAuInputInternetTicketEquipmentDetail
  } from "../../../../../../api/subwayRat/TVMRevenueVarianceAudit.TvmChaYiDXC/huLianWangShoupiaoji/huLianWangShouPiaojiXianWang";

  export default {
    components:{
    },
    data() {
      return {
        headers:{},
        dialogVisible:false,
        list:[],
        option:{}
    }
    },
    created() {
    },
    methods: {
      getAuth(){
        const token = this.$store.getters.access_token;
        if (token) {
          this.headers['Authorization'] = 'Bearer ' + token// token
        }
      },
      uploadSuccess(response, file, fileList){
        this.list=response.data;
        this.dialogVisible=true;
        this.getOption();
        console.log(response, file, fileList)
      },
      exportData(){
        let th=this;
        import_xc_result({}).then(res=>{
          if(res.data.code==0){
            th.$message.success("操作成功！");
            th.$emit("importSuccess");
            th.dialogVisible=false;
          }else{
            this.$message.error(res.data.msg);
          }
        })
      },
      getOption(){
        this.option  = {
          height:'auto',
          columnBtn:false,
          selection:false,
          refreshBtn:false,
          header:false,
          menu:false,
          emptyBtn:false,
          border: true,
          index: true,
          indexLabel: '序号',
          selection: true,
          reserveSelection:true,
          stripe: true,
          menuAlign: 'center',
          editBtn: false,
          delBtn: false,
          align: 'center',
          addBtn: false,
          //线路	站点	设备号	单价/元	发售数量	发售金额/元

          column: [{label:"日期", prop:"revenueDate"},
           //{label:"结束日期", prop:"endTime"},
            {label:"线路", prop:"lineName"},
            {label:"站点", prop:"stationName"},
            {label:"设备号", prop:"equipment_code"},
            {label:"问题种类", prop:"question_type"},
            {label:"中软-发售数量", prop:"sale_nums_zr"},
            {label:"中软-发售金额", prop:"sale_amount_zr"},
            {label:"水单-发售数量", prop:"sale_nums_cz"},
            {label:"水单-发售金额", prop:"sale_amount_cz"},
            {label:"差异-发售数量", prop:"sale_nums_cy"},
            {label:"差异-发售金额", prop:"sale_amount_cy"},
            {label:"确认结算-发售数量", prop:"sale_nums_confirm"},
            {label:"确认结算-发售金额", prop:"sale_amount_confirm"},
            {label:"差异原因", prop:"reason"},
          ]
        }

      }
    },
    mounted() {
      this.getAuth();
    }
  }
</script>
<style lang="scss">
  .Export.daoru{
    display: inline-flex;
    .el-upload-list{
      display: none;
    }
    .avue-crud__menu{
      display: none;
    }
  }

</style>
